﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using EnvironmentalMonitor.Support.Business.Manage;
using EnvironmentalMonitor.Support.Resource;

namespace EnvironmentalMonitor.WebApplication.Manage.User
{
    public partial class ChangePassword : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ButtonSubmit_Click(object sender, EventArgs e)
        {
            if (this.Page.IsPostBack)
            {
                bool done = false;

                EnvironmentalMonitor.Support.Module.Manage.User sessionUser = this.Session[Constant.SESSION_KEY_USER] as EnvironmentalMonitor.Support.Module.Manage.User;

                UserBusiness business = new UserBusiness();

                if (sessionUser.Password == this.TextBoxOldPassword.Text)
                {
                    done = business.ChangePassword(sessionUser.Guid, this.TextBoxNewPassword.Text);
                }

                if (done)
                {
                    sessionUser.Password = this.TextBoxNewPassword.Text;
                    this.LabelMessage.Text = "修改密码成功！";
                }
                else
                {
                    this.LabelMessage.Text = "修改密码失败！";
                }
            }
        }
    }
}